//
//  PersonData.swift
//  Swift列表显示
//
//  Created by 伍银荣 on 2021/12/10.
//  Copyright © 2021 com.WYR. All rights reserved.
//

import UIKit

class PersonData: NSObject {
   @objc var name: String?
   @objc var age: Int = 0
    
    //初始化构造函数
    init(dict: [String: AnyObject]) {
        //先初始化父类的实例
        super.init()
        //字典转模型
        setValuesForKeys(dict)
        
    }
    override func setValue(_ value: Any?, forKey key: String) {
        super .setValue(value, forKey: key) //这句一定要写
    }
    
    //对象描述信息,有利于开发调试
    override var description: String {
        //定义一个数组
        let keys = ["name", "age"]
        //模型转字典
        return "\(dictionaryWithValues(forKeys: keys))"
        
    }
    
}
